<template>

	<div class="active">
		<teaheader></teaheader>
		<div class="send_mesage">
			<textarea class="mesage_content" v-model="message1"></textarea>
			<button class="sead_btn" @click="sendActive()">发送活动短信</button>
			<textarea class="mesage_content" v-model="message2"></textarea>
			<button class="sead_btn" @click="sendPost()">发送开通短信</button>
		</div>
		<div class="prize">
			<div class="prize_top"></div>
			<div class="prize_bom"></div>
			<div class="prize_tit">奖品介绍</div>
			<ul class="prize_prize">
				<li>
					<div class="one"><img src="./img/tashan.png" /></div>
					<div class="two">美的遥控塔扇<br/>一等奖1名</div>
				</li>
				<li>
					<div class="one"><img src="./img/zhigao.png" /></div>
					<div class="two">志高挂烫机<br/>二等奖2名</div>
				</li>
				<li>
					<div class="one"><img src="../../index/img/tiantangsan.png" /></div>
					<div class="two">精美天堂太阳伞<br/>三等奖10名</div>
				</li>

			</ul>
		</div>
		<div class="active_regular">
			<div class="regular_tit">活动规则</div>
			<ul class="prize_ul">
				<li class="prize_li">
					<span class="box">01</span>
					<span class="box1">教师每发送一次活动短信，可获得 50 积分（每天发送多次仅统计一次）</span>
				</li>
				<li class="prize_li">
					<span class="box">02</span>
					<span class="box1">教师每发送一次开通短信，可获得 100 积分（每天发送多次仅统计一次）</span>
				</li>
				<li class="prize_li">
					<span class="box">03</span>
					<span class="box1">未开通学生每天进入一个学科的活动，对应的学科教师可获得10积分（每天只记录一次）</span>
				</li>
				<li class="prize_li">
					<span class="box">04</span>
					<span class="box1">已开通学生每天进入其开通学科的活动，对应的教师可获得20积分（每天只记录一次）</span>
				</li>
				<li class="prize_li no_last">
					<span class="box">05</span>
					<span class="box1">老师按照积分排名，在活动结束后会获得相应的奖品</span>
				</li>
				<li class="prize_li last_box">
					<span class="box">06</span>
					<span class="box1 ">活动礼品兑换会在15个工作日内配送，礼品以学校为单位进行统一配送，图片仅供参考，最终解释权归同步课堂所有，有问题请联系在线客服:12556185</span>
				</li>
			</ul>
		</div>
		<div class="back_top" @click="gotop()"></div>
		<teafooter></teafooter>
	</div>
</template>

<script>
	import searchToMap from '@/utils/searchToMap'
	export default {
		data() {
			return {
				message1: '家长好！暑假来临，为了丰富学生的暑假生活，同步课堂网站特别推出“语文亲子阅读”、“数学暑假作业大作战”、“英语我爱记单词”三项暑假系列活动，每项活动可有选择的独立参加，趣味测试，挑战高分，更有丰富奖品等您来拿！建议学生参与学习活动获得积分赢大奖。请协助孩子登录同步课堂手机客户端（app下载地址：m.tbkt.cn）如使用中遇到问题，请拨打客服电话：12556185进行咨询。',
				message2: '家长你好! 暑假来临，同步课堂网站特别推出语、数、外系列活动，丰富孩子暑假生活的同时，还有大奖可得。请协助孩子登录同步课堂手机客户端（app下载地址：m.tbkt.cn）参与活动，如使用中遇到问题，请拨打客服电话：12556185进行咨询。',
				stu_all: '',
				unit_id: this.$store.state.class_id, //班级ID
				bind_id: '', //所有学生ID
				stu_open: ""
			}

		},
		created() {
			var search = searchToMap();
			if(search && search.tbkt_token) {
				this.$store.commit('saveTeaMsg', search);
			}
		},
		methods: {
			showApi(){
				this.$http.get(domain + '/API/SummerAct/GetSortByInte', {
					params: {
						'intcityID': this.$store.state.city_id,
						'intType': 1,
						'intUserID': this.$store.state.tea_id
						}
					}).then(res => {
						let teamsg = res.body[0];
						if(!teamsg) return;
						this.$store.commit('changeTeaMsg', teamsg);
				})
			},
			sendActive() {
				layer.confirm('确认要下发短信吗？', () => {
					this.$http.post(mapi + "/class/sendsms", {
						'unit_id': this.unit_id,
						'content': this.message1
					}).then(res => {
						layer.closeAll();
						this.stu_all = this.message1;
						console.log(this.stu_all)
						this.$http.get(domain + '/API/SummerAct/SendMsg', {
							params: {
								'intType': 0,
								'intTeaID': this.$store.state.tea_id,
								'strTeaName': this.$store.state.tea_name,
								'strSendTime': new Date().Format('yyyy-MM-dd hh:mm:ss'),
								'intSID': this.$store.state.school_id,
								'strSName': this.$store.state.school_name,
								'intcityID': this.$store.state.city_id
							}
						}).then(res => {
							let finall = res.body;
							console.log(res.body)
							layer.tips("邀请短信发送成功")
							if(finall.success == true) {
								showApi()
							}
						})
					});
				}, () => {
					return;
				});

			},
			sendPost() {
				layer.confirm('确认要下发短信吗', () => {
					this.$http.post(mapi + '/class/students', {
						'unit_id': this.unit_id
					}).then(res => {
						layer.closeAll();
						let stu_all_id = res.body.data.students;
						console.log(res.body)
						var arr_bind_id = [];
						$.each(stu_all_id, function(i, value) {
							this.bind_id; //this指向当前元素
							arr_bind_id.push(this.bind_id)
						});
						let str_bind_id = arr_bind_id.join(",")
						this.$http.post(mapi + '/class/opensubject', {
							'bind_id': str_bind_id
						}).then(res => {
							console.log(str_bind_id)
							this.stu_open = this.message2;
							this.$http.get(domain + '/API/SummerAct/SendMsg', {
								params: {
									'intType': 1,
									'intTeaID': this.$store.state.tea_id,
									'strTeaName': this.$store.state.tea_name,
									'strSendTime': new Date().Format('yyyy-MM-dd hh:mm:ss'),
									'intSID': this.$store.state.school_id,
									'strSName': this.$store.state.school_name,
									'intcityID': this.$store.state.city_id
								}
							}).then(res => {
								let finall = res.body;
								layer.tips("开通短信发送成功")
								if(finall.success == true) {
									showApi()
								}
							})
						})

					});
				}, () => {
					return;
				});

			},
			gotop() {
				document.body.scrollTop = 0;
			}
		}
	}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
	@import "../../../assets/scss/_mixin";
	.active {
		padding-bottom: 150px/$ppr;
		width: 100%;
		background-color: #fff7b3;
		.send_mesage {
			width: 660px/$ppr;
			margin: 0 auto;
			padding-bottom: 80px/$ppr;
			height: 350px/$ppr;
			font-size: 24px/$ppr;
			.mesage_content {
				box-sizing: border-box;
				width: 440px/$ppr;
				height: 140px/$ppr;
				resize: none;
				/*	overflow: hidden;*/
				line-height: 40px/$ppr;
				padding: 20px/$ppr;
				margin-right: 0;
				float: left;
				margin: 20px/$ppr 0;
				color: #999999;
				border: 1px solid #333333;
				border-radius: 6px/$ppr;
				box-shadow: 0 1px 10px/$ppr #cdd0cf;
			}
			.sead_btn {
				width: 190px/$ppr;
				height: 76px/$ppr;
				background-image: url(./img/magess_btn1.png);
				background-size: 100% 100%;
				line-height: 76px/$ppr;
				text-align: center;
				float: left;
				margin: 58px/$ppr 0px/$ppr 58px/$ppr 30px/$ppr;
				color: #FFFFFF;
				border: none;
				outline: none;
			}
		}
		.prize {
			box-sizing: border-box;
			clear: both;
			width: 660px/$ppr;
			height: 460px/$ppr;
			margin: 0 auto;
			border-radius: 20px/$ppr;
			border: 1px solid #333333;
			position: relative;
			background-color: #FFFFFF;
			padding-top: 30px/$ppr;
			.prize_top {
				position: absolute;
				z-index: 2;
				left: 100px/$ppr;
				top: -17px/$ppr;
				width: 68px/$ppr;
				height: 30px/$ppr;
				background-image: url(./img/prize_top.png);
				background-size: 100% 100%;
			}
			.prize_bom {
				position: absolute;
				z-index: 2;
				left: 520px/$ppr;
				bottom: -17px/$ppr;
				width: 68px/$ppr;
				height: 30px/$ppr;
				background-image: url(./img/prize_bom.png);
				background-size: 100% 100%;
			}
			.prize_tit {
				width: 210px/$ppr;
				height: 84px/$ppr;
				margin: 0 auto;
				background-image: url(./img/prize_intro.png);
				background-size: 100% 100%;
				line-height: 120px/$ppr;
				font-size: 28px/$ppr;
				font-weight: 800;
				text-align: center;
			}
			.prize_prize {
				width: 100%;
				margin-top: 60px/$ppr;
				li {
					width: 33.33%;
					float: left;
					div.one {
						display: block;
						width: 160px/$ppr;
						height: 160px/$ppr;
						margin: 0 auto;
						background-color: #65e871;
						border-radius: 5px/$ppr;
						img {
							display: block;
							width: 100%;
							height: 100%;
						}
					}
					.two {
						font-size: 24px/$ppr;
						text-align: center;
						line-height: 40px/$ppr;
						margin: 20px/$ppr 0;
					}
				}
			}
		}
		.active_regular {
			width: 630px/$ppr;
			height: 722px/$ppr;
			margin: 0 auto;
			margin-top: 34px/$ppr;
			font-size: 24px/$ppr;
			.regular_tit {
				box-sizing: border-box;
				width: 214px/$ppr;
				height: 80px/$ppr;
				background-image: url(./img/regular.png);
				background-size: 100% 100%;
				margin: 0 auto;
				text-align: center;
				padding-top: 40px/$ppr;
			}
			.prize_ul {
				margin-top: 50px/$ppr;
				.prize_li {
					height: 100px/$ppr;
					line-height: 50px/$ppr;
					span {
						display: inline-block;
						float: left;
					}
					.box {
						width: 34px/$ppr;
						color: #FFFFFF;
						font-size: 34px/$ppr;
						font-weight: bold;
						-webkit-text-stroke: #000 1px/$ppr;
						text-align: left;
					}
					.box1 {
						width: 554px/$ppr;
						margin-left: 20px/$ppr;
					}
				}
				.no_last {
					height: 50px/$ppr;
				}
				.last_box {
					height: 150px/$ppr;
				}
			}
		}
		.back_top {
			width: 46px/$ppr;
			height: 46px/$ppr;
			background-image: url(./img/back_top1.png);
			background-size: 100% 100%;
			float: right;
			margin-right: 30px/$ppr;
		}
	}
</style>